import requests

if __name__ == '__main__':
    url = 'https://www.baidu.com/'

    headers = {
        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36",
        # "content-type": "text/html;charset=UTF-8"
    }

    resp = requests.get(url, headers=headers)
    # resp.encoding = 'utf-8'
    # print(resp.text)

    with open('baidu.html', 'w', encoding='utf-8') as f:
        f.write(resp.text)
